package com.technique.api.user;

import java.security.Principal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Service;

import com.monkeyk.sos.domain.dto.UserJsonDto;
import com.monkeyk.sos.domain.shared.security.WdcyUserDetails;
import com.technique.api.model.User;


@Service("feifanUserService")
public class FeifanUserService {

	@Autowired
	private com.monkeyk.sos.service.UserService userService;
	
	public User getUserInfo(Principal principal){
		if(principal !=null && principal instanceof OAuth2Authentication){
			Object p = ((org.springframework.security.oauth2.provider.OAuth2Authentication)principal).getPrincipal();
			if(p!= null && p instanceof WdcyUserDetails){
				return new User(((WdcyUserDetails)p).user());
			}
		}
		return null;
	}
	
	
}
